#include "spaceMgr.h"
#ifdef WIN32
#define usleep(x) Sleep(x)
#endif
#include "DiskSpace.h"

DiskSpaceMgr::DiskSpaceMgr(std::string dir_,char disk_, int fsl_)
	: logDir_(dir_),DiskStr(disk_),freeSizeLimit(fsl_)
{
}

DiskSpaceMgr::~DiskSpaceMgr(void)
{

}

void* DiskSpaceMgr::run()
{
	int _totalSize = 0;
	int _freeSize = 0;
	while (true)
	{
		if (pyfree::getDiskFreeSpace(DiskStr, _totalSize, _freeSize) > 0)
		{
			if (freeSizeLimit > _freeSize)
			{
				pyfree::moveOldFile(logDir_, "log");
			}
		}
		sleep(10);
	}
	return NULL;
}
